/*
 * @version: 
 * @Author: yu
 * @Date: 2023-06-27 15:24:02
 * @LastEditors: Andy
 * @LastEditTime: 2023-06-29 17:13:57
 */
import { menuList } from '@/request/api'

//声明state
const state = {
    list: []  //菜单列表
}

//修改state
const mutations = {
    changeList(state, arr) {
        state.list = arr
    }
}

const actions = {
    listActions(context) {
        //发起菜单列表请求
        menuList({ istree: true }).then(res => {
            // console.log(res);
            if (res.code === 200) {
                context.commit('changeList', res.list)
            }
        })
    }
}

//派生状态
const getters = {
    list(state) {
        return state.list
    }
}

export default {
    state,
    mutations,
    actions,
    getters,
    namespaced: true,   //启用命名空间
}